package com.sky;



import com.alibaba.fastjson.JSON;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class redisText {

    @Test
    public void aa()throws Exception{
        //创建HttpClient对象 客户端对象
        CloseableHttpClient client = HttpClients.createDefault();
        //创建请求对象
        HttpGet httpGet = new HttpGet("https://query.asilu.com/weather/baidu/?city=武汉");

        //使用客户端 发生请求
        CloseableHttpResponse response = client.execute(httpGet);
        //获取响应体
        int statusCode = response.getStatusLine().getStatusCode();
        System.out.println("您的状态码为:"+statusCode);

        HttpEntity entity = response.getEntity();
        String body = EntityUtils.toString(entity);

        System.out.println("您的数据为"+body);
        System.out.println(entity);

        response.close();
        httpGet.clone();
    }
}
